<div class="gray_box">
    <?php include_partial('tabs', array('selected' => $sf_request->getParameter('action'))) ?>
    <div class="registration_wrap">
        <br/>
        <div class="inner_blue_title"><?php echo __('Preview') ?></div>
        <br/>
        <?php include('flashes.php') ?>
        <br/>
        <br/>
        <div class="registration_form_wrap">
            <div class="preview_dos_wrapper">
                <?php if (count($arr) > 0) { ?>

                    <?php foreach ($arr as $course => $dos) { ?>
                        <div class="dos_wrrap">
                            <div class="dos_course_group">
                                <h4><?php echo $course ?></h4>
                            </div>
                            <ul class="doss">
                                <?php foreach ($dos as $k => $one) { ?>


                                    <li class="preview_dos_item" id="dos_id_<?php $one['id'] ?>">
                                        <?php $local_path = sfConfig::get('sf_web_dir') . '/uploads/doseyeh/' . $one['cover_image'] ?>
                                        <div class="dos_thumb" style="background-image:url('<?php echo get_resized_image(152, 184, $local_path, 'width') ?>')">
                                            <a href="<?php echo url_for('doseyeh/show?id=' . $one['id']) ?>"><img src="<?php echo image_path('doseyeh_cover.png') ?>"/></a>
                                        </div>
                                        <div class="dos_rating" data-did="<?php echo $one['id'] ?>" data-rating="<?php echo $one['rating'] ?>"></div>
                                        <div class="dos_course"><?php echo $one['dos_name'] ?></div>
                                        <div class="dos_doctor"><?php echo $one['course_name'] ?></div>
                                        <?php if (isset($_COOKIE['rated_' . $one['id']])) { ?> 
                                            <script>
                                                $(document).ready(function(){  
                                                    $('#dos_id_'+'<?php echo $one['id'] ?> .dos_rating').raty('readOnly', true);
                                                });
                                            </script>
                                        <?php } ?>
                                    </li>
                                <?php } ?>
                                <?php if (!count($dos)) { ?>
                                    <div class="no_results">
                                        <h6><?php echo __("-- No Results") ?></h6>
                                    </div>
                                <?php } ?>
                            </ul>
                        </div>
                    <?php } ?>

                <?php } else { ?>
                    <center>- <?php echo __('no results found') ?> -</center>
                <?php } ?>
            </div>
            <div class="clear"></div>
        </div>
    </div>
</div>
<script>
    $('.dos_rating').raty({
        path: '<?php echo public_path('images/raty/', true) ?>'
        ,size: 22
        ,start: function() {
            return $(this).attr('data-rating');
        }
        ,click: function(rate){
            _rate_elem = this;
            _did = $(this).attr('data-did');
            $.cookie('rated_'+_did, true, '/');
            $.ajax({
                url: "<?php echo url_for('user/rate_dos') ?>?rate="+rate+"&did="+_did,
                context: document.body
            }).done(function(data) { 
                $(_rate_elem).raty('start', data);
                $(_rate_elem).raty('readOnly', true);
            });
        }
    });
    
</script>